/**
 * Created by Administrator on 2016/4/29.
 */
$(function(){

    $.getJSON("hxclub/activity/activitys.do",{pid:id1,pageNo:1,pageSize:100},function(json){
        console.info(json)
        var $varietyContent = $('#drbd'), varietyHtml = template('detai2', json);
        $varietyContent.html(varietyHtml);
    })

    $.ajax({
        url: "hxclub/activity/byIdContent.do",
        async: false,
        type : "get",
        dataType : "json",
        data:{id:id1},
        success : function(data){console.info(data)
            var $varietyContent = $('#content'), varietyHtml = template('detail', data);
            $varietyContent.html(varietyHtml);
            $("head title").html($("#content h2").html());

            var imgs = $(".X3Articl img");
            if(imgs.length>1){
                $(".X3Articl img:last").hide();
            }
            if(imgs.length<1){
                $(".X3Articl img:first").hide();
            }

            /*  var $varietyContent = $('#nav_fangwen'), varietyHtml = template('nav_list', data);
             $varietyContent.html(varietyHtml);*/
            $(".gwant").click(function(){
             /*   alert("请访pc官网进行报名")*/
                  $.ajax({
                 url: "hxclub/sys/heart.do",
                 async: false,
                 type : "post",
                 dataType : "json",
                 success:function(d){
                 if(d.success){
                     var datatime = $("#shijian").val();
                 if(datatime == "1"){
                 alert("该活动已经报名")
                     return;
                 } else if(datatime == '2') {
                     alert("该活动已过期")
                     return;
                 }

                 }
                 else{
                 alert("请先登录后再报名");
                 window.location.href = 'login.html?redirectUrl=allactive.html?id='+id1;
                 }
                     $.ajax({
                         method:"POST",
                         url:"hxclub/activity/join.do",
                         data:{
                             //uid:uid,
                             aid:id1
                         },
                         dataType:"JSON",
                         success:function(data){
                             if(data.statusCode==200){
                                 alert(data.data);

                             }else{
                                 alert(data.data);

                             }
                         }

                     })
                 }
                 });
            })
        }
    });
    $("#l_img img").mousedown(function(){
        $(this).attr("src","images/gWant1.png");
    });
    $("#l_img img").mouseup(function(){
        $(this).attr("src","images/gWant.png");
    });
})